<?php
include('auth.php');
include('../config.php');

if ($_SESSION['AUTH_LEVEL'] >=3) { 
	$forWhom     = $_GET['user'];
	$amount      = $_GET['amount'];
	
	mysql_connect($host,$username,$password);
	mysql_select_db($database);
	
	$saldo  = mysql_query("SELECT kontostand FROM saufanten WHERE name = '".$forWhom."'"); 
	list($saldo)  = mysql_fetch_row($saldo);
	
	$newSaldo = $saldo + $amount;
	$notice = "Einzahlung von ".$_SESSION['Admin'] ." => ".$forWhom;
	
	$result = mysql_query("INSERT INTO buchungen (name, booked, konto, anmerkung) 
				                          VALUES ('".$forWhom."','".$amount ."','".$newSaldo ."','".$notice."')");
				   
	$result = mysql_query("UPDATE saufanten Set kontostand = '".$newSaldo."' WHERE name = '".$forWhom."'");
	
	echo($newSaldo);
}
